﻿using IBll;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Model;

namespace WebApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class HoomController : ControllerBase, IHoomBll
    {
        public HoomController(IHoomBll bll)
        {
            Bll = bll;
        }

        public IHoomBll Bll { get; }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="hoom">实体</param>
        /// <returns>返回受影响行数</returns>
        [HttpPost]
        public Task<int> AddHoom(Hoom hoom)
        {
            try//异常处理
            {
                return Bll.AddHoom(hoom);
            }
            catch (Exception)
            {

                throw;
            }
           
        }
        /// <summary>
        /// 类型列表
        /// </summary>
        /// <returns>返回受影响行数</returns>
        [HttpGet]
        public List<HoomType> GetHoomType()
        {
            try//异常处理
            {
                return Bll.GetHoomType();
            }
            catch (Exception)
            {

                throw;
            }
           
        }
        /// <summary>
        /// 显示
        /// </summary>
        /// <param name="hoomnumber">房号查</param>
        /// <param name="typeId">类型查</param>
        /// <returns>返回受影响行数</returns>
        [HttpGet]
        public dynamic GetHoom(string? hoomnumber, int typeId)
        {
            try//异常处理
            {
                return Bll.GetHoom(hoomnumber, typeId);
            }
            catch (Exception)
            {

                throw;
            }
            
        }
        /// <summary>
        /// 反填
        /// </summary>
        /// <param name="id">反填id</param>
        /// <returns>返回受影响行数</returns>
        [HttpGet]
        public Hoom FanTian(int id)
        {
            try//异常处理
            {
                return Bll.FanTian(id);
            }
            catch (Exception)
            {

                throw;
            }
           
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="hoom">实体</param>
        /// <returns>返回受影响行数</returns>
        [HttpPut]
        public Task<int> UpdaHoom(Hoom hoom)
        {
            try//异常处理
            {
                return Bll.UpdaHoom(hoom);
            }
            catch (Exception)
            {

                throw;
            }
            
        }
    }
}
